﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;

namespace DateTimeZoneTests
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("What does DateTime and DateTimeOffest look like?");
            Console.WriteLine(DateTime.Now);
            Console.WriteLine(DateTimeOffset.Now);
            Console.WriteLine();

            DateTime dateTime1 = DateTime.Now;
            DateTime dateTime2 = DateTime.UtcNow;
            Console.WriteLine("DateTime.Now - DateTime.UtcNow = {0} - {1} = {2}", dateTime1, dateTime2, dateTime1 - dateTime2);
            Console.WriteLine();

            DateTimeOffset offset1 = DateTimeOffset.Now;
            DateTimeOffset offset2 = DateTimeOffset.UtcNow;
            Console.WriteLine("DateTimeOffset.Now - DateTimeOffset.UtcNow = {0} - {1} = {2}", offset1, offset2, offset1 - offset2);
            Console.WriteLine();

            Console.Write("Your time zone info: ");
            Console.WriteLine(TimeZoneInfo.Local);

            DateTimeOffset current = DateTimeOffset.Now;
            ReadOnlyCollection<TimeZoneInfo> timeZones = TimeZoneInfo.GetSystemTimeZones();
            Console.WriteLine("You might be in the following time zones:");
            foreach (var timeZoneInfo in timeZones)
            {
                // Compare offset with offset for that date in that time zone
                if (timeZoneInfo.GetUtcOffset(current).Equals(current.Offset))
                {
                    Console.WriteLine("   {0}", timeZoneInfo.DisplayName);
                }
            }
            Console.ReadKey();
        }
    }
}
